/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import request from '@/utils/request';
import { message } from 'antd';

// 获取数据库列表
export async function getDbName(params: any) {
  return request('/showProcessList/getDbName', {
    method: 'POST',
    data: params,
  }).then((res) => {
    const { code, data, msg } = res;
    if (code == 0) {
      return Object.keys(data).map((item: any) => ({
        label: item,
        value: item,
      }));
    } else {
      message.error(msg);
      return [];
    }
  });
}

// 获取列表
export async function showProcessList(params: any) {
  return request('/showProcessList/showProcessList', {
    method: 'POST',
    data: params,
  });
}

// 删除指定进程
export async function killProcess(params: any) {
  return request('/showProcessList/killProcess', {
    method: 'POST',
    data: params,
  });
}

// 执行sql
export async function querySql(params: any) {
  return request('/showProcessList/querySql', {
    method: 'POST',
    data: params,
  });
}
